package com.tarena.lbs.user.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.lbs.user.dao.mapper.AdminMapper;
import com.tarena.lbs.user.dao.repository.AdminRepository;
import com.tarena.lbs.user.pojo.po.AdminPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

    @Repository
    @Slf4j
    public class AdminRepositoryImpl implements AdminRepository {
        @Autowired
        AdminMapper  adminMapper;
        @Override
        public AdminPO adminLogin(String phone) {
            log.info("管理员登录：{}", phone);
            AdminPO adminPO= adminMapper.adminLogin(phone);
            return adminPO;
        }
        @Override
        public AdminPO getById(Integer id) {
            log.debug("查询用户详情,repository层");
            return adminMapper.selectById(id);
        }
        @Override
        public List<AdminPO> list() {
            log.debug("查询所有用户,repository层");
            List<AdminPO> list = adminMapper.AdminVOList();
            return list;
        }
        @Override
        public Long count(QueryWrapper queryWrapper) {
            log.debug("查询phone数量,repository层");
            Long count = adminMapper.selectCount(queryWrapper);
            return count;
        }

        @Override
        public void save(AdminPO adminPO) {
            adminMapper.insert(adminPO);
        }
    }


